// 2010 >> Asia - Jakarta LA5061 Lightning Energy Report
// 基于LCA的树上差分解法, 陈锋
#include <bits/stdc++.h>
using namespace std;
const int NN = 50000 + 4;
vector<int> G[NN], Pre;
int N, L, Tin[NN], Tout[NN], UP[NN][18], timer;  // LCA相关
void init() {
  Pre.clear(), L = ceil(log2(N)), timer = 0;
  for (int i = 0; i <= N; i++) G[i].clear();
}
void addEdge(int u, int v) { G[u].push_back(v), G[v].push_back(u); }
void dfs(int u, int fa = 0) {
  Pre.push_back(u), Tin[u] = ++timer, UP[u][0] = fa;
  for (int i = 1; i <= L; i++) UP[u][i] = UP[UP[u][i - 1]][i - 1];
  for (size_t i = 0; i < G[u].size(); i++)
    if (G[u][i] != fa) dfs(G[u][i], u);
  Tout[u] = ++timer;
}
bool isAncestor(int u, int v) { return Tin[u] < Tin[v] && Tout[v] < Tout[u]; }
int lca(int u, int v) {
  if (isAncestor(u, v)) return u;
  if (isAncestor(v, u)) return v;
  for (int i = L; i >= 0; --i)
    if (!isAncestor(UP[u][i], v)) u = UP[u][i];
  return UP[u][0];
}
int mark[NN];
int main() {
  int T;
  cin >> T;
  for (int kase = 1, Q, x, y; kase <= T; kase++) {
    cin >> N, init(), fill_n(mark, N + 1, 0);
    for (int i = 1; i < N; i++) cin >> x >> y, addEdge(x, y);
    dfs(0, 0);
    cin >> Q;
    for (int i = 0, c; i < Q; i++) {
      cin >> x >> y >> c;
      int d = lca(x, y), pd = UP[d][0];
      mark[x] += c, mark[y] += c, mark[d] -= c;
      if (pd != d) mark[pd] -= c;
    }
    for(int i = Pre.size() - 1; i > 0; i--)
      mark[UP[Pre[i]][0]] += mark[Pre[i]];
    printf("Case #%d:\n", kase);
    for (int i = 0; i < N; i++) printf("%d\n", mark[i]);
  }
}
/*
算法分析请参考: 《入门经典训练指南-升级版》3.7 例题38
注意本题的树上差分的实现要注意lca的父亲的判断
*/
// Accepted 130ms 1932 C++5.3.0 2020-12-13 22:25:38 25843936